{% extends "admin/base.html" %}
{% load i18n %}

{% block header %}
<script type="text/javascript" src="/senbzblog/static/tinymce/tiny_mce.js"></script>
<script type="text/javascript" src="/senbzblog/static/admin/js/utils.js"></script>
<script type="text/javascript" src="/senbzblog/static/admin/js/tinymceinit.js"></script>
{% endblock %}

{% block content %}
<div>
	<h2 class="title1">{% if page %}{% trans "Edit page" %}{% else %}{% trans "Add page" %}{% endif %}</h2>
	{% if messages %}
	<ul class="messages">
		{% for message in messages %}
		<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
		{% endfor %}
	</ul>
	{% endif %}
	<form action="{% url admin_save_page user.username %}" method="post" class="full-width">
		<div>
			{{ pageform.id }}
			{{ pageform.is_published }}
			{{ pageform.blog }}
		</div>
		<div id="poststuff" class="metabox-holder">
			<div class="inner-sidebar">
				<div>
					<div class="dashboard-window">
						<h3>{% trans "Property" %}</h3>
						<div class="inside">
							<p class="sub">{% trans 'Display order' %}</p>
							<div class="table">
								{{ pageform.order }}
								<input type="hidden" id="ordered_values" name="ordered_values" />
								<table>
									<tr>
										<td style="border: 0px;">
											<select id="display_orders" onfocus="this.defOpt=this.selectedIndex" 
												onchange="this.selectedIndex=this.defOpt;" size="8" name="display_orders"
												style="width: 100%;">
												{% for page in pages %}
												<option {% ifequal current_page page.id %}selected{% endifequal %}
													value={{ page.id }}>{{ page.title }}</option>
												{% endfor %}
												{% if not page %}
												<option selected value="0">New page</option>
												{% endif %}
											</select>
										</td>
										<td style="width: 20px">
											<label for="display_orders">
												<table>
													<tr><td style="text-align: right;">
														<img src="/static/images/arrow-up.png" style="cursor: pointer;"
															onclick="senbz.operation.move_select('display_orders', false, 'ordered_values')" /></td>
													</tr>
													<tr><td style="text-align: right;">
														<img src="/static/images/arrow-down.png" style="cursor: pointer;"
															onclick="senbz.operation.move_select('display_orders', true, 'ordered_values')" /></td>
													</tr>
												</table>
											</label>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>
					<div class="dashboard-window">
						<h3>{% trans "Publish" %}</h3>
						<div>
							<div id="minor-publishing-actions">
								<span>
									{{ pageform.allow_comment }} 
									{{ pageform.allow_comment.label_tag }} <br/>
								</span>
								<div>
									<input type="submit" class="button" tabindex="4" 
										value="{% trans 'Save' %}" id="save-post" name="save">
									{% if page.is_published %}
								  	<input type="submit" value="{% trans 'Cancel Publish' %}" tabindex="5" 
								  		id="publish" class="button-primary alignright" name="unpublish">
								  	{%else%}
								  	<input type="submit" value="{% trans 'Publish' %}" tabindex="5" 
								  		id="publish" class="button-primary alignright" name="publish">
								  	{%endif%}
								</div>
								<div class="clear"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="has-sidebar">
				<div id="post-body-content" style="margin-right: 305px;">
					<div class="form-field">
						{{ pageform.title }}
						{% if pageform.title.errors %}
						{{ pageform.title.errors }}
						{% endif %}
					</div>
					<div class="form-field">
						{{ pageform.contents }}
						{% if pageform.contents.errors %}
						{{ pageform.contents.errors }}
						{% endif %}
					</div>
					<div class="form-field">
						<div class="dashboard-window">
							<h3>{{ pageform.slug.label_tag }}<span class="red">*</span></h3>
							{{ pageform.slug }}
							{% if pageform.slug.errors %}
							{{ pageform.slug.errors }}
							{% else %}
							<p class="help_text">{{ pageform.slug.help_text }}</p>
							{% endif %}
						</div>
					</div>
				</div>
			</div>
			<b><br class="clear"></br></b>
		</div>
	</form>
</div>
{%endblock%}
